<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <canvas id="canvas" height="600" width="700"></canvas>
  <script>
    // 获取 canvas 元素
    var canvas = document.getElementById('canvas');
    var ctx = canvas.getContext('2d');
    // 创建渐变
    var gradient1 = ctx.createRadialGradient(175, 150, 0, 175, 150, 150);
    gradient1.addColorStop(0, "skyblue");
    gradient1.addColorStop(1, "#fffc96");
    var gradient2 = ctx.createRadialGradient(525, 150, 100, 525, 150, 150);
    gradient2.addColorStop(0, "skyblue");
    gradient2.addColorStop(1, "#fffc96");
    var gradient3 = ctx.createRadialGradient(175, 450, 0, 300, 450, 150);
    gradient3.addColorStop(0, "skyblue");
    gradient3.addColorStop(1, "#fffc96");
    var gradient4 = ctx.createRadialGradient(525, 450, 200, 525, 450, 0);
    gradient4.addColorStop(0, "skyblue");
    gradient4.addColorStop(1, "#fffc96");
    ctx.beginPath()
    ctx.fillStyle = gradient1
    ctx.fillRect(0, 0, 350, 300)
    ctx.strokeRect(0, 0, 350, 300)
    ctx.beginPath()
    ctx.fillStyle = gradient2
    ctx.fillRect(350, 0, 350, 300)
    ctx.strokeRect(350, 0, 350, 300)
    ctx.beginPath()
    ctx.fillStyle = gradient3
    ctx.fillRect(0, 300, 350, 300)
    ctx.strokeRect(0, 300, 350, 300)
    ctx.beginPath()
    ctx.fillStyle = gradient4
    ctx.fillRect(350, 300, 350, 300)
    ctx.strokeRect(350, 300, 350, 300)
  </script>
</body>

</html>